package algorithm.dynamicProgramming;

//机器人走迷宫,问从(0,0)出发，到其对角，一共有多少种走法
public class RobotWalkingMaze {
    public static void main(String[] args) {
        int[][] map = new int[2][2];
        System.out.println(counts(2, 2));
    }

    /**
     * @param m 迷宫的行数
     * @param n 迷宫的列数
     * @return
     */
    public static int counts(int m, int n) {
        int[][] f = new int[m][n];
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (i == 0 || j == 0) {
                    f[i][j] = 1;
                } else {
                    f[i][j] = f[i - 1][j] + f[i][j - 1];
                }

            }

        }
        return f[m - 1][n - 1];
    }
}
